package com.hgvip.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * Created by arnold.zhu on 2017/8/1.
 */
@Configuration
@EnableScheduling
public class ScheduleConfig {

    private final Logger logger = LoggerFactory.getLogger(ScheduleConfig.class);

    /***
     * 基于Spring的定时任务
     */

    @Scheduled(cron = "0/10 * * * * ?")
    public void scheduler1() {
        logger.error("============== Spring scheduler1 每10秒执行1次 ===============");
    }

    @Scheduled(cron = "0/5 * * * * ?")
    public void scheduler2() {
        logger.error("============== Spring scheduler2 每5秒执行1次 ===============");
    }

}
